package com.hogae.capital.service.impl;

import java.util.List;

import com.hogae.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hogae.capital.mapper.CapAccountMapper;
import com.hogae.capital.domain.CapAccount;
import com.hogae.capital.service.ICapAccountService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 资金账户Service业务层处理
 *
 * @author hogae
 * @date 2021-02-26
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class CapAccountServiceImpl implements ICapAccountService {
    @Autowired
    private CapAccountMapper capAccountMapper;

    /**
     * 查询资金账户
     *
     * @param id 资金账户ID
     * @return 资金账户
     */
    @Override
    public CapAccount selectCapAccountById(Long id) {
        return capAccountMapper.selectCapAccountById(id);
    }

    /**
     * 查询资金账户列表
     *
     * @param capAccount 资金账户
     * @return 资金账户
     */
    @Override
    public List<CapAccount> selectCapAccountList(CapAccount capAccount) {
        return capAccountMapper.selectCapAccountList(capAccount);
    }

    /**
     * 新增资金账户
     *
     * @param capAccount 资金账户
     * @return 结果
     */
    @Override
    public int insertCapAccount(CapAccount capAccount) {
        capAccount.setCreateTime(DateUtils.getNowDate());
        return capAccountMapper.insertCapAccount(capAccount);
    }

    /**
     * 修改资金账户
     *
     * @param capAccount 资金账户
     * @return 结果
     */
    @Override
    public int updateCapAccount(CapAccount capAccount) {
        capAccount.setUpdateTime(DateUtils.getNowDate());
        return capAccountMapper.updateCapAccount(capAccount);
    }

    /**
     * 批量删除资金账户
     *
     * @param ids 需要删除的资金账户ID
     * @return 结果
     */
    @Override
    public int deleteCapAccountByIds(Long[] ids) {
        return capAccountMapper.deleteCapAccountByIds(ids);
    }

    /**
     * 删除资金账户信息
     *
     * @param id 资金账户ID
     * @return 结果
     */
    @Override
    public int deleteCapAccountById(Long id) {
        return capAccountMapper.deleteCapAccountById(id);
    }
}
